﻿using Pay.Dal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pay.Model.Model;
using Pay.Dapper;
using Pay.Model;
using Dapper.Contrib.Extensions;
using Dapper;
namespace Pay.DalImplement
{
    public class MerchantDalImplement : IMerchantDal
    {
        /// <summary>
        /// 根据ID查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<MerchantInfo> GetById(long id)
        {
            try
            {
                string sql = "select * from merchant_info where id=@id";
                using (var conn = ConnectionFactory.GetReadConnection())
                {
                    return await conn.QueryFirstOrDefaultAsync<MerchantInfo>(sql, new { id = id });
                }
            }
            catch (Exception ec)
            {

                throw;
            }
          
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<bool> Update(MerchantInfo info)
        {
            using (var conn = ConnectionFactory.GetWriteConnection())
            {
                return await conn.UpdateAsync<MerchantInfo>(info);
            }
        }
    }
}
